<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>添加体制测试</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <style>
        .form-items-show {
            display: none;
        }
    </style>
</head>

<body ng-app="app" ng-controller="addContextController">

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">

            <div class="layui-col-md11">

                <div class="layui-card">
                    <div class="layui-card-header"><a href="javascript:history.go(-1);">返回上一页</a>添加体质测试</div>
                    <div class="layui-card-body">
                        <form class="layui-form" action="" lay-filter="component-form-element" id="component-form-group">
                            <div class="layui-row layui-col-space10 layui-form-item">

                                <div class="layui-col-lg6">
                                    <label class="layui-form-label">类型选择</label>
                                    <div class="layui-input-block">
                                        <select name="conditionType" lay-verify="required" lay-filter="aihao" id="conditionType" ng-model="conType" ng-change="getConditionTypeContext()">
                                          <option value=''>无</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">

                                    <div class="layui-input-block">
                                        <button class="layui-btn layui-btn-warm" type="button" ng-click="getConditionTypeContext()">选中确定</button>
                                        <a class="layui-btn layui-btn-danger" href="../../component/form/addcondition-type.html">+增加体质测试类型</a>
                                    </div>

                                </div>
                            </div>
                            <div class="form-items-show">


                                <div class="layui-row layui-col-space10 layui-form-item">
                                    <div class="layui-col-lg3">
                                        <label class="layui-form-label">{{Conditioncontext.height}}</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="height" lay-verify="required" placeholder="保留两位小数" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>

                                    <div class="layui-col-lg3">
                                        <label class="layui-form-label">{{Conditioncontext.weight}}</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="width" lay-verify="required" placeholder="保留两位小数" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-col-lg3">
                                        <label class="layui-form-label">{{Conditioncontext.abduction}}</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="abduction" lay-verify="required" placeholder="保留两位小数" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-col-lg3">
                                        <label class="layui-form-label">{{Conditioncontext.fingerSpan}}</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="fingerSpan" lay-verify="required" placeholder="保留两位小数" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                </div>


                                <div class="layui-form-item">
                                    <label class="layui-form-label">{{Conditioncontext.singForward}}</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="singForward" placeholder="保留两位小数" lay-verify="required" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">{{Conditioncontext.roundTrip}}</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="roundTrip" placeholder="整数" lay-verify="required" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">{{Conditioncontext.courtSprint}}</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="courtSprint" placeholder="保留两位小数" lay-verify="required" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">{{Conditioncontext.restrtedArea}}</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="restrtedArea" placeholder="保留两位小数" lay-verify="required" class="layui-input">
                                    </div>
                                </div>


                                <div class="layui-form-item">
                                    <label class="layui-form-label">{{Conditioncontext.klingWing}}</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="klingWing" placeholder="保留两位小数" lay-verify="required" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">{{Conditioncontext.verticalJump}}</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="verticalJump" placeholder="整数" lay-verify="required" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">{{Conditioncontext.continJump}}</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="continJump" placeholder="整数" lay-verify="required" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label"> 备注:</label>
                                    <div class="layui-input-block">
                                        <textarea name="remake" placeholder="备注内容" lay-verify="required" class="layui-textarea"></textarea>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label"> </label>
                                    <div class="layui-input-block">
                                        <input type="checkbox" name="agreement" title="已阅读相关条款" lay-skin="primary" checked>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="component-form-element">立即提交</button>
                                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                        <a class="layui-btn layui-btn-primary" href="javascript:history.go(-1);">返回</a>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="../../../layuiadmin/jquery/jquery-1.11.1.min.js"></script>
    <script src="../../../layuiadmin/url.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/jquery/angular.js"></script>
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form'], function() {
            var $ = layui.$,
                admin = layui.admin,
                element = layui.element,
                form = layui.form;

            $(function() {

                var arr = [];
                $.ajax({
                    url: applicationUrl + 'no-constionparent/api/list',
                    type: "POST",
                    dataType: "json",
                    success: function(data) {
                        arr.push(data);

                        for (var i = 0; i < data.length; i++) {
                            $("#conditionType").append("<option value='" + data[i].cid + "'>" + data[i].content + "</option>");
                        }
                        form.render(); //注意渲染页面表单，否则不显示数据
                    }
                });





            });
            //获取url地址栏
            function getQueryVariable(variable) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i = 0; i < vars.length; i++) {
                    var pair = vars[i].split("=");
                    if (pair[0] == variable) {
                        return pair[1];
                    }
                }
                return (false);
            }


            form.render(null, 'component-form-element');
            element.render('breadcrumb', 'breadcrumb');

            form.on('submit(component-form-element)', function(data) {
                var sid = getQueryVariable("sid");
                //  layer.msg(JSON.stringify(data.field));
                var conditionType = data.field.conditionType;
                var height = data.field.height;
                var width = data.field.width;
                var abduction = data.field.abduction;
                var fingerSpan = data.field.fingerSpan;
                var singForward = data.field.singForward;
                var roundTrip = data.field.roundTrip;
                var courtSprint = data.field.courtSprint;
                var restrtedArea = data.field.restrtedArea;
                var klingWing = data.field.klingWing;
                var verticalJump = data.field.verticalJump;
                var continJump = data.field.continJump;
                var remake = data.field.remake;


                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: applicationUrl + 'no-constitution/api/insert',
                    data: {
                        sid: sid,
                        conditionType: conditionType,
                        height: height,
                        width: width,
                        abduction: abduction,
                        fingerSpan: fingerSpan,
                        singForward: singForward,
                        roundTrip: roundTrip,
                        courtSprint: courtSprint,
                        restrtedArea: restrtedArea,
                        klingWing: klingWing,
                        verticalJump: verticalJump,
                        continJump: continJump,
                        remake: remake,

                    },
                    success: function(result) {
                        layer.msg(result.msg);
                        $("#component-form-group")[0].reset();
                        layui.form.render();

                    },
                    error: function(result) {
                        layer.msg(result.msg);

                        layui.form.render();
                    }

                })
                return false;
            });
        });

        $("#sexRadio1").prop("checked", true);


        var app = angular.module('app', []);
        app.controller('addContextController', ['$scope', '$http', function($scope, $http) {
            $scope.getConditionTypeContext = function() {
                var cid = $("#conditionType").val();
                console.log(cid);
                if (cid != "") {
                    $(".form-items-show").attr("style", "display:block");
                    console.log("ok");
                    // var sid = getQueryVariable("sid");
                    $http({
                        method: 'POST',
                        url: applicationUrl + 'no-constionparent/api/byCid',
                        headers: {
                            "Content-Type": 'application/x-www-form-urlencoded'
                        },
                        params: {
                            cid: cid
                        },
                    }).success(function(result) {
                        $scope.Conditioncontext = result.data;
                    }).error(function(data, status) {
                        console.log(" ");
                    });
                } else {
                    console.log("no");
                }


            };





        }]);
    </script>
</body>

</html>